package com.example.sherlockzhong.plush_v2.Subscriptions;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.RelativeLayout;

import com.example.sherlockzhong.plush_v2.Components.buttons.BackButton;
import com.example.sherlockzhong.plush_v2.Models.EcardModel;
import com.example.sherlockzhong.plush_v2.R;
import com.umeng.analytics.MobclickAgent;

/**
 * Created by DosonLeung on 2014/9/20.
 */
public class SubscriptionActivity extends Activity {
    RelativeLayout subscription_map;
    RelativeLayout subscription_news;
    RelativeLayout subscription_class;
    RelativeLayout subscription_teacher;
    RelativeLayout subscription_todo;
    RelativeLayout subscription_lesson;
    RelativeLayout subscription_exam;
    RelativeLayout subscription_grade;
    RelativeLayout subscription_weather;
    RelativeLayout subscription_consumption;
    RelativeLayout Subscription_poster;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.subscription);
        initWidget();
        initOnClickEvent();
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    private void initWidget() {
        subscription_map = (RelativeLayout) findViewById(R.id.subscription_map);
        subscription_news = (RelativeLayout) findViewById(R.id.subscription_news);
        subscription_class = (RelativeLayout) findViewById(R.id.subscription_class);
        subscription_teacher = (RelativeLayout) findViewById(R.id.subscription_teacher);
        subscription_todo = (RelativeLayout) findViewById(R.id.subscription_todo);
        subscription_lesson = (RelativeLayout) findViewById(R.id.subscription_lesson);
        subscription_exam = (RelativeLayout) findViewById(R.id.subscription_exam);
        subscription_grade = (RelativeLayout) findViewById(R.id.subscription_grade);
        subscription_weather = (RelativeLayout) findViewById(R.id.subscription_weather);
        subscription_consumption = (RelativeLayout) findViewById(R.id.subscription_consumption);
        Subscription_poster = (RelativeLayout) findViewById(R.id.subscription_poster);
        BackButton subscription_back = (BackButton) findViewById(R.id.subscription_back);
        subscription_back.setApp(this);
    }

    private void initOnClickEvent() {

        subscription_map.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, MapActivity.class);
                startActivity(intent);
            }
        });
        subscription_news.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, OrganizationActivity.class);
                startActivity(intent);
            }
        });
        subscription_class.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, ClassActivity.class);
                startActivity(intent);
            }
        });
        subscription_teacher.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, TeacherActivity.class);
                startActivity(intent);
            }
        });
        subscription_todo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SubscriptionActivity.this, TodoActivity.class);
                startActivity(intent);
            }
        });
        subscription_lesson.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, ScheduleActivity.class);
                startActivity(intent);
            }
        });
        subscription_exam.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, ExamActivity.class);
                startActivity(intent);
            }
        });
        subscription_grade.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, GradeActivity.class);
                startActivity(intent);
            }
        });
        subscription_weather.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, WeatherActivity.class);
                startActivity(intent);
            }
        });
        subscription_consumption.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (EcardModel.isVerify()) {
                    Intent intent = new Intent(SubscriptionActivity.this, ConsumptionActivity.class);
                    startActivity(intent);
                } else {
                    Intent intent = new Intent(SubscriptionActivity.this, ConsumptionActivity.class);
                    startActivity(intent);
                }
            }
        });
        Subscription_poster.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SubscriptionActivity.this, PosterActivity.class);
                startActivity(intent);
            }
        });
    }
}
